<?php

namespace app\model;

use think\Model;

class OrderAddress extends Model
{

    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'order_address';


    public static function getaddress($order, $ptype = 1)
    {
        $addressdata = self::where(['order_num_alias' => $order['order_num_alias'], 'ptype' => $ptype])->order('id desc')->find()?->toArray();
        if (empty($addressdata)) {
            $addressdata = self::where(['order_id' => $order['id'], 'ptype' => $ptype])->order('id desc')->find()?->toArray();
        }

        return $addressdata;
    }
}
